package BusquedaLocal;

import aima.search.framework.Successor;
import aima.search.framework.SuccessorFunction;
import java.util.ArrayList;
import java.util.List;

public class LSSuccessorFunction implements SuccessorFunction {
    public List getSuccessors(Object aState) {
String S = "";
        ArrayList retVal = new ArrayList();
        Board board = (Board) aState;
        LSHeuristicFunction HF = new LSHeuristicFunction();
        int num_furgonetas = board.numero_furgonetas();
        int num_estaciones = board.numero_estaciones();
        for (int i = 0; i < num_furgonetas; i++) {
            if (!board.utilizada(i)) {
                for (int j = 0; j < num_estaciones; j++) {
                    //if (!board.estacion_asignada(j)) {
                        for (int z = 0; z<num_estaciones; z++) {
                            if (z!=j) {
                                for (int q = -1; q<num_estaciones; q++) {
                                    if (q!=z && q!=j) {
                                        Board newBoard = new Board(board);
                                        newBoard.asignar_destinos(i,j,z,q);
                                        double v = -HF.getHeuristicValue(newBoard);
                                        S = newBoard.datos_furgoneta(i);
                                        retVal.add(new Successor(S, newBoard));
                                        //System.out.println(v);
                                    }
                                }
                            }
                        }
                    //}
                }
            }
        }
        return retVal;
    }
}
